﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BUS;
using DTO;

namespace DentalSoftware
{
    public partial class PhieuChi : Form
    {
        public PhieuChi()
        {
            InitializeComponent();
            txtMaPhieu.Text = ThuChiBUS.GetMaxMa().ToString();
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
            this.Close();
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            PhieuThuChiDTO ptc = new PhieuThuChiDTO();
            ptc.Ngay = new DateTime(dtpNgay.Value.Year, dtpNgay.Value.Month, dtpNgay.Value.Day);
            ptc.Nguoithuchien = txtNguoiThucHien.Text;
            ptc.Diachi = txtDiaChi.Text;
            ptc.Dienthoai = mtbDienThoai.Text;
            ptc.Noidung = txtNoiDung.Text;
            ptc.Sotien = float.Parse(mtbSoTien.Text);
            ptc.Loai = 0;

            ThuChiBUS.InsertPhieu(ptc);
            this.DialogResult = DialogResult.Yes;
            this.Close();            
        }        
    }
}
